﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

namespace Amoo.Banner
{
    public partial class BannerTopo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MontarBanners();
        }

        private void MontarBanners()
        {

            List<Code.Entity.Banner> retListFederal;
            List<Code.Entity.Banner> retListEstadual;
            List<Code.Entity.Banner> retListMunicipal;

            using (Code.Data.Banner oBanner = new Amoo.Code.Data.Banner())
            {
                retListFederal = oBanner.GetAll("F");
                oBanner.Dispose();
                retListEstadual = oBanner.GetAll("E");
                oBanner.Dispose();
                retListMunicipal = oBanner.GetAll("M");
                oBanner.Dispose();
            }

            MontarBannerFederal(retListFederal);
            MontarBannerEstadual(retListEstadual);
            MontarBannerMunicipal(retListMunicipal);
        }

        private void MontarBannerFederal(List<Code.Entity.Banner> retList)
        {
            string strHtml = "";

            strHtml = "<div style='display:' ><img src='/Images/logo_amoo.JPG' height='68'  width='138px' alt=''/></div>";
            
            foreach (Code.Entity.Banner eBanner in retList)
            {

                strHtml += "<div style='display:none' ><a href='" + eBanner.dsPalavrasBusca + "' target='_Blank'><img src='/Userfiles/" + eBanner.dsArquivo.ToString() + "' height='68'  width='138px' alt='' border='0'/></a></div>";
            }


            dvBannerFederal.InnerHtml = strHtml;
        }

        private void MontarBannerEstadual(List<Code.Entity.Banner> retList)
        {
            string strHtml = "";

            strHtml = "<div style='display:' ><img src='/Images/logo_amoo.JPG' height='68'  width='138px' alt=''/></div>";

            foreach (Code.Entity.Banner eBanner in retList)
            {

                strHtml += "<div style='display:none' ><a href='" + eBanner.dsPalavrasBusca + "' target='_Blank'><img src='/Userfiles/" + eBanner.dsArquivo.ToString() + "' height='68'  width='138px' alt='' border='0'/></a></div>";
            }


            dvBannerEstadual.InnerHtml = strHtml;
        }

        private void MontarBannerMunicipal(List<Code.Entity.Banner> retList)
        {
            string strHtml = "";
            int iUltimo = 3;


            strHtml = "<div style='display:' ><img src='/Images/logo_amoo.JPG' height='68'  width='138px' alt=''/></div>";

            dvBannerMunicipal1.InnerHtml = strHtml;
            dvBannerMunicipal2.InnerHtml = strHtml;
            dvBannerMunicipal3.InnerHtml = strHtml;



            foreach (Code.Entity.Banner eBanner in retList)
            {

                strHtml = "<div style='display:none' ><a href='" + eBanner.dsPalavrasBusca + "' target='_Blank'><img src='/Userfiles/" + eBanner.dsArquivo.ToString() + "' height='68'  width='138px' alt='' border='0'/></a></div>";

                switch (iUltimo)
                {
                    case 3:
                        dvBannerMunicipal1.InnerHtml += strHtml;
                        iUltimo = 1;
                        break;
                    case 1:
                        dvBannerMunicipal2.InnerHtml += strHtml;
                        iUltimo = 2;
                        break;
                    case 2:
                        dvBannerMunicipal3.InnerHtml += strHtml;
                        iUltimo = 3;
                        break;
                }
            }

        }

    }
}
